﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lxzhu.OpenGL;
namespace Tutorials
{
    class HelloGL : TimedGlutEngine
    {
        public static void Main(string[] args)
        {
            HelloGL rt = new HelloGL() { Title="Hello GL", Interval = 10 };
            rt.Run();
        }
        private float mBase = 1.0f;
        private bool mLarger = false;
        public override void OnDisplay()
        {
            base.OnDisplay();
            Gl.glClear(BufferBit.GL_COLOR_BUFFER_BIT);
            Gl.glColor(1.0f, 0.0f, 0.0f);
            Gl.glBegin(PrimitiveType.GL_POLYGON);
            Gl.glVertex(0.25f * mBase, 0.25f * mBase, 0.0f);
            Gl.glVertex(0.75f * mBase, 0.25f * mBase, 0.0f);
            Gl.glVertex(0.75f * mBase, 0.75f * mBase, 0.0f);
            Gl.glVertex(0.25f * mBase, 0.75f * mBase, 0.0f);
            Gl.glEnd();
           
        }
       
        public override void OnTimeOut(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (mLarger)
            {
                this.mBase += 0.02f;
                if (this.mBase >= 1.0)
                    mLarger = false;
            }
            else
            {
                this.mBase -= 0.02f;
                if (this.mBase <= 0.1)
                {
                    mLarger = true;
                }
            }
        }

    }
}
